<!--  -->
<template>
  <div>
    <el-dialog title="提示" :visible.sync="dialog" width="60%" :before-close="handleClose">
      <el-form ref="form" :model="classform" label-width="80px">
        <el-form-item label="活动名称">
          <el-input v-model="classform.name"></el-input>
        </el-form-item>
        <el-form-item label="宿舍描述">
          <el-input v-model="classform.bak"></el-input>
        </el-form-item>
        <el-form-item label="详细地址">
          <el-input v-model="classform.position"></el-input>
        </el-form-item>
        <el-form-item label="宿舍类型">
          <el-select v-model="classform.type" placeholder="选择男女宿舍">
            <el-option
              v-for="item in types"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            ></el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="时间">
          <el-date-picker
            type="date"
            value-format="yyyy-MM-dd"
            v-model="classform.startTime"
            placeholder="开始时间"
          ></el-date-picker>
          <el-date-picker
            type="date"
            value-format="yyyy-MM-dd"
            v-model="classform.endTime"
            placeholder="结束时间"
          ></el-date-picker>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialog= false">取 消</el-button>
        <el-button type="primary" @click="doSave">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { studentDetail } from "@/api/xy/student";
import { detail, classUpdate, classSave } from "@/api/xy/class";
export default {
  name: "classDetail",
  data() {
    return {
      dialog: false,
      classform: {},
      types: [
        {
          label: "男",
          value: 0,
        },
        {
          label: "女",
          value: 1,
        },
        {
          label: "未定",
          value: 2,
        },
      ],
    };
  },
  computed: {},
  created() {},
  mounted() {},
  methods: {
    handleClose() {
      this.dialog = false;
    },
    doSave() {
      var api = null;
      if (this.classform.id) {
        api = classUpdate;
      } else {
        api = classSave;
      }
      

      api({
        xyclassInfo:{
        ...this.classform,
      }
      })
      .then((res) => {
        if (res.code ) {
          this.$message.success("保存成功");
          this.handleClose();
          this.$parent.getclassList()
        } else {
          this.$message.error("保存失败");
        }
      });
    },
    openDialog() {
      this.dialog = true;
    },
    openDialogDetail(id) {
      this.openDialog();
      detail({ id }).then((res) => {
        // console.log(res)
        this.classform = res.data;
        console.log(this.classform);
      });
    },
  },
};
</script>

<style lang='scss' scoped >
</style>
H